package busca.tesoros.uclm;

import android.app.Activity;
import android.util.Log;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ArrayAdapter;
import android.widget.ImageView;
import android.widget.TextView;

public class MyPerformanceArrayAdapter extends ArrayAdapter<String> 
{
	private final Activity context;
	private final String[] names;
	private final String[] estado;

	public MyPerformanceArrayAdapter(Activity context, String[] names, String[] estado) 
	{
		super(context, R.layout.lista, names);
		this.context = context;
		this.names = names;
		this.estado = estado;
	}
	
	public View getView(int position, View convertView, ViewGroup parent)
	{
		Log.i("Cliente","GetView en Myperfomance");
		LayoutInflater inflater = context.getLayoutInflater();
		View rowView = inflater.inflate(R.layout.lista, null,true);
		TextView textView = (TextView)rowView.findViewById(R.id.label);
		ImageView imageView = (ImageView)rowView.findViewById(R.id.icon);
		String e = estado[position];
		String s = names[position];
		textView.setText(s);
		/*for (int i=0;i<names.length;i++)
		{*/
		int i=position;
			if(e.equals("nueva"))
			{
				textView.setText(names[i]);
				Log.i("Cliente","GetView en Myperfomance: If-Nueva");
				imageView.setImageResource(R.drawable.nueva);
			}
			else if(e.equals("Realizandose"))
			{
				textView.setText(names[i]);
				Log.i("Cliente","GetView en Myperfomance: If-Realizandose");
				imageView.setImageResource(R.drawable.prog);
			}
			else if(e.equals("completada"))
			{
				
				textView.setText(names[i]);
				rowView.setClickable(false);
				rowView.setEnabled(false);
				Log.i("Cliente","GetView en Myperfomance");
				imageView.setImageResource(R.drawable.ok);
			}
		
		return rowView;
	}
}